package com.biyabi.controller;

import com.biyabi.pojo.Result;
import com.biyabi.pojo.UsersData;
import com.biyabi.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/back/user")
public class UserController {
    @Resource
    private UserService userService;
    @RequestMapping("/findAll")
    public UsersData findAll(Integer page, Integer rows, String columnName, String columnValue){
        return userService.findAll(page,rows,columnName,columnValue);
    }

    @RequestMapping("/updateUserStatus")
    public Result updateUserStatus(String id,Integer status){
        Result result = new Result();
        try{
            userService.updateUserStatus( id,status);
            result.setStatus(true);
            if(status==0)
                result.setMessage("冻结用户成功！");
            else
                result.setMessage("用户恢复正常成功！");
        }catch(Exception e){
            result.setStatus(false);
            if(status==0)
                result.setMessage("冻结用户失败！");
            else
                result.setMessage("用户恢复正常失败！");
        }
        return result;
    }

}
